package cn._51doit.flink.day02.sources;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.types.LongValue;
import org.apache.flink.util.LongValueSequenceIterator;

import java.util.Arrays;

/**
 *
 * 基于集合的【多并行的】Source都是有限的数据流，数据处理完，程序退出
 */
public class ParCollectionSource1 {

    public static void main(String[] args) throws Exception {

        Configuration configuration = new Configuration();
        configuration.setInteger("rest.port", 8081);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(configuration);

        DataStreamSource<LongValue> nums = env.fromParallelCollection(new LongValueSequenceIterator(1, 10), LongValue.class);
        System.out.println("fromParallelCollection创建的DataStream的并行度：" + nums.getParallelism());
        nums.print();

        env.execute();

    }
}
